package com.ramesh.fragmenttabhostdemo;


import android.app.AlertDialog;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;


public class CustomMapFragment extends Fragment  {

	GoogleMap mMap;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
	}
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		View v = LayoutInflater.from(getActivity()).inflate(R.layout.mapcountries, null);
		
		if (getArguments() != null) {
			//
			try {
			     getArguments().getString("key");
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return v;
	}
	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		CheckGoogleMapAvailability();
		initMap();
	}
	private void CheckGoogleMapAvailability() {
		// TODO Auto-generated method stub
		GooglePlayServicesUtil.isGooglePlayServicesAvailable(getView().getContext().getApplicationContext());
		
//		if (!available) {
//			AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getView().getContext());
//			alertDialogBuilder.setTitle("ERROR GOOGLE MAP");
//
//			alertDialogBuilder
//			.setMessage("GOOGLE PAY SERVISE IS NOT AVAILABLE")
//			.setCancelable(false)
//			.setNeutralButton("Close", null);
//			// create alert dialog
//			AlertDialog alertDialog = alertDialogBuilder.create();
//			alertDialog.show();
//		}
//		// show it
		
	}
	private void initMap() {
		// TODO Auto-generated method stub
		mMap = ((SupportMapFragment)getFragmentManager().findFragmentById(R.id.map)).getMap();
//		mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
//		mMap.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker"));
//		mMap.setMyLocationEnabled(true);
	}
}
